#include "Nest.h"
#include "ResourceManagers.h"
#include "ChickenDefGame.h"
#include "GUIOverlay.h"

#include <sstream>

const float Nest::maxTemp=100;

Nest::Nest(){
    sf::Image *i=ImageManager::Instance()->GetImage("nest.png");
	SetImage(*i);
	SetPosition(400,300);
	SetCenter(i->GetWidth()/2, i->GetHeight()/2);
	Reset();
	GUIOverlay::Instance()->SetHeatMaxMin(100.0f,0.0f);
}

void Nest::SetGame(ChickenDefGame* _game){
	game=_game;
}


void Nest::Reset(){

	currentChicken=NULL;
	temp=100;

}

Nest *Nest::Instance(){
    static Nest instance;
    return &instance;
}


void Nest::SetChicken(Chicken *current){
	currentChicken=current;
}


Chicken * Nest::GetChicken(){
	return currentChicken;
}




void Nest::Update(float dt){
	temp-=3*dt;
	GUIOverlay::Instance()->SetHeat(temp);

	if(temp<=0)
		game->GameOver();
}

void Nest::AddTemp(float cant){
	temp+=cant;
	if(temp>maxTemp) temp=maxTemp;
	if(temp<0) temp=0;
}
